<admintpl file="header"/>
</head>
<body>
<div class="wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:U('Admin/News/index')}">新闻列表</a></li>
    </ul>
    <form method="post" class="form-horizontal js-ajax-form" action="{:U('Admin/News/edit_post')}">
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">新闻标题：</label>

            <div class="span3">
                <input type="text" name="newsTitle" style="width: 556px;" value="{$data.newsTitle}">
            </div>
        </div>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">新闻分类：</label>

            <div class="span3">
                <select class="select_2" name="upperId" id="upperId">
                    <foreach name="cates" item="vo">
                        <option value="{$vo.cateId|number_format=0,'',''}">{$vo.cateName}</option>
                    </foreach>
                </select>
            </div>
            <if>
                <div class="span3">
                    <select class="select_2" name="categoryId" id="categoryId">
                        <if condition="empty($cate2s)">
                            <option value="0">--无--</option>
                        </if>
                        <foreach name="cate2s" item="vo">
                            <option value="{$vo.cateId|number_format=0,'',''}">{$vo.cateName}</option>
                        </foreach>
                    </select>
                </div>
        </div>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">新闻图片：</label>

            <div style="padding-left: 130px;text-align: left;">
                <input type="hidden" name="imageUrl" id="imageUrl" value="{$data.newsUrl}">
                <a href="javascript:void(0);"
                   onclick="flashupload('thumb_images', '附件上传','imageUrl',thumb_images,'1,jpg|jpeg|gif|png|bmp,1,,,1','','','');return false;">
                    <img src="{$data.newsUrl}" onerror="this.src='__TMPL__Public/assets/images/default-thumbnail.png'"
                         id="imageUrl_preview" width="135" style="cursor: hand"/>
                </a>
            </div>
        </div>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">新闻类型：</label>

            <div class="span3">
                <label class="radio inline" for="lightup_true">
                    <input type="radio" id="lightup_true"  class="radio" name="newsType" value="1"  <if condition="$data['newsType'] eq '1' "> checked</if>/>专题新闻</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <label class="radio inline" for="lightup_false">
                    <input type="radio" id="lightup_false" class="radio" name="newsType" value="0"   <if condition="$data['newsType'] eq '0' "> checked</if>/>普通新闻</label>
            </div>
        </div>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">关联专题：</label>

            <div class="span3">
                <select class="select_2" name="channelId" id="channelId">
                    <option>全部</option>
                    <foreach name="subject" item="vo">
                        <option value="{$vo.cateId}">{$vo.cateName}</option>
                    </foreach>
                </select>
            </div>
            <div class="span3">
                <select class="select_2" name="subjectId" id="subjectId">
                    <option value="">--无--</option>
                </select>
            </div>
            <div class="span3">
                <a href='{:U("Admin/Subject/add")}'>新建专题</a>
            </div>
        </div>
        <div class="control-group">
            <label class="span2 control-label" style="width: 90px;">新闻摘要：</label>

            <div class="span7">
                <textarea style="width: 556px; height: 60px;" name="newsVeneto"> {$data.newsTitle}</textarea>
            </div>
        </div>
        <div class="control-group">
            <label class="span2 control-label" style="width: 90px;">新闻正文：</label>

            <div class="span9">
                <script type="text/plain" id="content" name="newsContent">{$data.newsContent}</script>
            </div>
        </div>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">是否原创：</label>

            <div class="span3">
                <label class="radio inline" for="lightup_true"> <input type="radio" class="radio" name="isOriginal"
                                                                       value="1"
                    <if condition="$data['isOriginal'] eq '1' "> checked</if>
                    />开启</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <label class="radio inline" for="lightup_false"> <input type="radio" class="radio"
                                                                        name="isOriginal" value="0"
                    <if condition="$data['isOriginal'] eq '0' "> checked</if>
                    />关闭</label>
            </div>
        </div>
        <div class="form-actions" style="padding-left:260px;">
            <input type="hidden" name="newsId" value="{$data.newsId}">
            <button type="submit" class="btn btn-primary js-ajax-submit">保存</button>
            &nbsp;&nbsp;<a class="btn" href="{:U('Admin/News/index')}">{:L('BACK')}</a>
        </div>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/content_addtop.js"></script>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.DIMAUB;
</script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var flag = true;
        $('#upperId').change(function () {
            $.get('{:U("Admin/News/ajax_get_cate")}' + '&upperId=' + $('#upperId').val(), function (data) {
                var html = '<option value="0">--无--</option>';
                if (data['state'] == "success") {
                    html = '<option value="-1">全部</option>';
                    for (var a in data.newsCategoryList) {
                        html += '<option value="' + data.newsCategoryList[a].cateId + '">' + data.newsCategoryList[a].cateName + '</option>';
                    }
                }
                $('#categoryId').html(html);
                if (flag) {
                    $('#categoryId').val({$data.categoryId
                })
                    ;
                }
                flag = false;
            });
        });

        $('#upperId').val({$data.upperId
    })
        ;
        $('#upperId').change();

        var flagSubject = true;
        $('#channelId').change(function () {
            $.get('{:U("Admin/News/ajax_get_subject")}' + '&cateId=' + $('#channelId').val(), function (data) {
                var html = '<option value="">--无--</option>';
                if (data['state'] == "success") {
                    html = '<option value="-1">全部</option>';
                    for (var a in data.tagList) {
                        html += '<option value="' + data.tagList[a].tagTitle + '">' + data.tagList[a].tagTitle + '</option>';
                    }
                }
                $('#subjectId').html(html);
                if (flagSubject) {
                    $('#subjectId').val("{$data.keywords}");
                }
                flagSubject = false;
            });
        });

        $('#channelId').val({$data.sub_upperId
    })
        ;
        $('#channelId').change();
    });
    $(function () {
        //编辑器
        editorcontent = new baidu.editor.ui.Editor();

        editorcontent.render('content');
        try {
            editorcontent.sync();
        } catch (err) {
        }
        //增加编辑器验证规则
        jQuery.validator.addMethod('editorcontent', function () {
            try {
                editorcontent.sync();
            } catch (err) {
            }
            return editorcontent.hasContents();
        });
        ////-------------------------
    });
</script>
</body>
</html>